<?php
namespace  app\middleware;
use app\service\PermissionService;
use think\facade\Log;
use think\Request;

/**
 * 权限中间件
 */
class  PermissionMiddleware{

    /**
     * 处理请求
     *
     * @param Request $request
     * @param Closure $next
     * @return Response
     */
    public function handle(Request $request,\Closure $next){
        $url=$request->url();
          $uid=$request->post('uid',0);
         $permissionData=PermissionService::getPermissionByUid($uid,$url);

         if ($permissionData==false){
            returnFail(22101,'操作权限不正确');
        }
         //从redis接口中获取数据
        return $next($request);
    }
}